package com.gxkj.projects.myshopx.entitys;

import com.gxkj.common.validate.Add;
import com.gxkj.common.validate.Update;
import com.gxkj.projects.myshopx.enums.*;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 商品品牌
 */
@Entity
@Table(name = "attribute")
public class Attribute extends BaseModel{
    private static final long serialVersionUID = 149973308615383461L;

    /**
     * 关联goods_type表id
     */
    @Column(name = "type_id")
    @NotBlank(message="{attribute.type_id.null}")
    private String typeId;

    /**
     * 属性名
     */
    @Column(name = "attr_name")
    @NotBlank(message = "{attribute.attr_name.null}")
    private String attrName;

    /**
     * 该属性值的录入方式
     */
    @Column(name = "attr_input_type")
    @NotNull(message = "{attr_input_type.null}")
    @Enumerated(EnumType.STRING)
    private AttributeInputTypeEnum attrInputType;

    /**
     * 属性类型
     * 唯一属性 单选属性 复选属性
     */
    @Column(name = "attr_type")
    @NotNull(message = "{attr_type.null}")
    @Enumerated(EnumType.STRING)
    private AttributeTypeEnum attrType;

    /**
     * 可选值列表
     */
    @Column(name = "attr_values")
    private String attrValues;

    /**
     * 索引范围
     */
    @Column(name = "index_range")
    @NotNull(message = "{attribute.index_range.null}" )
    @Enumerated(EnumType.STRING)
    private AttributeIndexRangeEnum indexRange;

    @Column(name="sort_order",nullable = false)
    private int sortOrder;//排序

    //相同属性值的商品是否关联
    @Column(name="linked",nullable = false)
    @org.hibernate.annotations.Type(type="yes_no")
    @NotNull(message = "{attribute.linked.null}" )
    private boolean  linked;

    @Column(name="attr_group",nullable = false)
    private String attrGroup;

    @Enumerated(EnumType.STRING)
    @Column(name="states",nullable = false)//状态
    @NotNull(message = "{states.null}")
    private AttributeStates states;


    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }


    public String getAttrName() {
        return attrName;
    }

    public void setAttrName(String attrName) {
        this.attrName = attrName;
    }



    public AttributeInputTypeEnum getAttrInputType() {
        return attrInputType;
    }

    public void setAttrInputType(AttributeInputTypeEnum attrInputType) {
        this.attrInputType = attrInputType;
    }



    public AttributeTypeEnum getAttrType() {
        return attrType;
    }

    public void setAttrType(AttributeTypeEnum attrType) {
        this.attrType = attrType;
    }

    public String getAttrValues() {
        return attrValues;
    }

    public void setAttrValues(String attrValues) {
        this.attrValues = attrValues;
    }



    public AttributeIndexRangeEnum getIndexRange() {
        return indexRange;
    }

    public void setIndexRange(AttributeIndexRangeEnum indexRange) {
        this.indexRange = indexRange;
    }

    public int getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(int sortOrder) {
        this.sortOrder = sortOrder;
    }



    public boolean isLinked() {
        return linked;
    }

    public void setLinked(boolean linked) {
        this.linked = linked;
    }

    public String getAttrGroup() {
        return attrGroup;
    }

    public void setAttrGroup(String attrGroup) {
        this.attrGroup = attrGroup;
    }



    public AttributeStates getStates() {
        return states;
    }

    public void setStates(AttributeStates states) {
        this.states = states;
    }
}
